package com.aabte.mybatis.mapper.controller;

import com.aabte.mybatis.mapper.bean.Employee;
import com.aabte.mybatis.mapper.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    @RequestMapping("/employee")
    public String employeeList(Map<String, Object> map){
        List<Employee> employeeList = employeeService.queryAllEmployee();
        map.put("employeeList", employeeList);
        return "list";
    }

    @ResponseBody
    @RequestMapping(value = "/rest/employee")
    public List<Employee> employees(){
        List<Employee> employees = employeeService.queryAllEmployee();
        return employees;
    }

}
